package com.bdqn.t382.factory;

import com.bdqn.t382.dao.NewsDao;
import com.bdqn.t382.dao.impl.NewsDaoImpl;
import com.bdqn.t382.dao.impl.NewsDaoMySqlImpl;
import com.bdqn.t382.dao.impl.NewsDaoOracleImpl;
import com.bdqn.t382.dao.impl.NewsDaoRedisImpl;

public class SimpleDaoFactory {
    public static NewsDao getInstance(String key) {
        //return new NewsDaoImpl();
        switch (key) {
            case "mysql":
                return new NewsDaoMySqlImpl();
            case "oracle":
                return new NewsDaoOracleImpl();
            case "redis":
                return new NewsDaoRedisImpl();
            default:
                throw new RuntimeException("无效的数据库类型：" + key
                        + " ，DAO 获取失败");
        }
    }
}
